/**
 * 所有的ajax服务调用
 */
CommonService = {
	'getAllProvince': function(){
		var lst_param = new Array();
		var str_param = lst_param.join('&');
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/common/getAllProvince',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
				
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'getCityListByProvinceId': function(province_id){
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('province_id=' + province_id);
		var str_param = lst_param.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/common/getCityListByProvinceId',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
				
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'getDistrictListByCityId': function(city_id){
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('city_id=' + city_id);
		var str_param = lst_param.join('&');

		var result = null;		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/common/getDistrictListByCityId',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
				
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
}


AdminService = {
	'Login' : function(cellphone, pwd) {
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('cellphone=' + cellphone);
		lst_param.push('password=' + pwd);
		var str_param = lst_param.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/admin/login',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
				
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'EmployeeLogin' : function(employee_id, employee_name, cellphone) {
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('employee_id='	+ employee_id);
		lst_param.push('employee_name=' + employee_name);
		lst_param.push('cellphone='		+ cellphone);
		var str_param = lst_param.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/admin/employeeLogin',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
				
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'Logout' : function() {
		// 登陆功能
		var lst_param = new Array();
		var str_param = lst_param.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/admin/logout',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'VerifyRegister': function(param_en){
		var lst_param = new Array();
		lst_param.push('promoter_type=' + param_en.promoter_type);
		lst_param.push('real_name='		+ param_en.real_name);
		lst_param.push('sex='			+ param_en.sex);
		lst_param.push('password='		+ param_en.password);
		lst_param.push('cellphone='		+ param_en.cellphone);
		lst_param.push('district_id='	+ param_en.district_id);
		lst_param.push('address='		+ param_en.address);
		lst_param.push('alipay_id='		+ param_en.alipay_id);
		lst_param.push('alipay_name='	+ param_en.alipay_name);
		lst_param.push('share_code='	+ param_en.share_code);
		lst_param.push('id_card_no='	+ param_en.id_card_no);
		var str_param = lst_param.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/admin/verifyRegister',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	
};


PromoterService = {
		'Withdraw': function(promoter_id, amount){
			// 申请提现
			var lst_param = new Array();
			lst_param.push('promoter_id=' + promoter_id);
			lst_param.push('amount=' + amount);
			var str_param = lst_param.join('&');

			
			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/promoter/withdraw',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'GetAmountList': function(promoter_id, page_index){
			var lst_param = new Array();
			lst_param.push('promoter_id=' + promoter_id);
			lst_param.push('page_index=' + page_index);
			var str_param = lst_param.join('&');

			
			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/promoter/getAmountList',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'GetWithdrawList': function(promoter_id, page_index){
			var lst_param = new Array();
			lst_param.push('promoter_id=' + promoter_id);
			lst_param.push('page_index=' + page_index);
			var str_param = lst_param.join('&');

			
			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/promoter/getWithdrawList',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'ReRegister': function(promoter_id){
			var lst_param = new Array();
			lst_param.push('promoter_id=' + promoter_id);
			var str_param = lst_param.join('&');

			
			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/promoter/reRegister',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'UpdatePwd': function(promoter_id, old_pwd, new_pwd, new_pwd2){
			var lst_param = new Array();
			lst_param.push('promoter_id=' + promoter_id);
			lst_param.push('old_pwd=' + old_pwd);
			lst_param.push('new_pwd=' + new_pwd);
			lst_param.push('new_pwd2=' + new_pwd2);
			var str_param = lst_param.join('&');

			
			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/promoter/updatePwd',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'UpdateInfo': function(param_en){
			var lst_param = new Array();
			lst_param.push('promoter_id=' + param_en.promoter_id);
			lst_param.push('real_name=' + param_en.real_name);
			lst_param.push('sex=' + param_en.sex);
			lst_param.push('password=' + param_en.password);
			lst_param.push('cellphone=' + param_en.cellphone);
			lst_param.push('district_id=' + param_en.district_id);
			lst_param.push('address=' + param_en.address);
			lst_param.push('alipay_id=' + param_en.alipay_id);
			lst_param.push('alipay_name=' + param_en.alipay_name);
			lst_param.push('business_license_no=' + param_en.business_license_no);
			lst_param.push('id_card_no=' + param_en.id_card_no);
			var str_param = lst_param.join('&');
			
			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/promoter/updateInfo',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
};


OrderService = {
		'CalcCartAmount': function(lst_sku){
			var lst_param = new Array();
			lst_param.push('lst_sku=' + lst_sku);
			var str_param = lst_param.join('&');

			var result = null;

			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/calcCartAmount',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
				error : function(e, err_name, err_text) {
					result = {};
					result.IsSuccess = 0;
					result.ErrorMsg = err_text;
					result.ErrorCode = 4;
				}
			});
			return result;
		},

		'AddAddress': function(param_en, lst_sku, user_id){
			var lst_param = new Array();
			lst_param.push('consignee_name=' + param_en.consignee_name);
			lst_param.push('consignee_cellphone=' + param_en.consignee_cellphone);
			lst_param.push('consignee_tel=' + param_en.consignee_tel);
			lst_param.push('consignee_zip=' + param_en.consignee_zip);
			lst_param.push('consignee_address=' + param_en.consignee_address);
			lst_param.push('district_id=' + param_en.district_id);
			lst_param.push('lst_sku=' + lst_sku);
			lst_param.push('user_id=' + user_id);
			var str_param = lst_param.join('&');
			
			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/addAddress',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'UpdateAddress': function(param_en, lst_sku){
			var lst_param = new Array();
			lst_param.push('address_id=' + param_en.address_id);
			lst_param.push('consignee_name=' + param_en.consignee_name);
			lst_param.push('consignee_cellphone=' + param_en.consignee_cellphone);
			lst_param.push('consignee_tel=' + param_en.consignee_tel);
			lst_param.push('consignee_zip=' + param_en.consignee_zip);
			lst_param.push('consignee_address=' + param_en.consignee_address);
			lst_param.push('district_id=' + param_en.district_id);
			lst_param.push('lst_sku=' + lst_sku);
			var str_param = lst_param.join('&');
			
			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/updateAddress',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'SubmitOrder': function(address_id, lst_sku){
			var lst_param = new Array();
			lst_param.push('address_id=' + address_id);
			lst_param.push('lst_sku=' + lst_sku);
			var str_param = lst_param.join('&');

			var result = null;
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/submitOrder',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'GetOrderList': function(promoter_id, type, index){
			var lst_param = new Array();
			lst_param.push('promoter_id=' + promoter_id);
			lst_param.push('type=' + type);
			lst_param.push('index=' + index);
			var str_param = lst_param.join('&');

			var result = null;
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/getOrderList',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'SearchOrder': function(keyword){
			var lst_param = new Array();
			lst_param.push('keyword=' + keyword);
			var str_param = lst_param.join('&');

			var result = null;
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/searchOrder',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'CancelOrder': function(order_id){
			var lst_param = new Array();
			lst_param.push('order_id=' + order_id);
			var str_param = lst_param.join('&');

			var result = null;
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/cancelOrder',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
};